package com.prd.controller;


import com.prd.dto.CustomerContactDTO;
import com.prd.service.CustomerContactService;
import com.prd.util.JsonData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 客户-备注总表 前端控制器
 * </p>
 *
 * @author o1
 * @since 2023-11-26
 */
@Api(tags={"客户管理-新增来源关系人等"})
@RestController
@RequestMapping("/api/customerContact")
public class CustomerContactController {

    private CustomerContactService contactService;

    public CustomerContactController(CustomerContactService contactService) {
        this.contactService = contactService;
    }

    @ApiOperation("客户模块-关系人-UNI-新增-type-客户关系人1 客户来源2，合伙人4\"")
    @PostMapping(value = "uAdd", produces = "application/json;charset=UTF-8")
    public JsonData uAdd(
            @ApiParam(value = "uAdd") @RequestBody CustomerContactDTO contactDTO) {
        return contactService.uAdd(contactDTO);
    }

    @ApiOperation("客户模块-关系人-UNI-更新原本未填写的信息")
    @PostMapping(value = "uUpdate", produces = "application/json;charset=UTF-8")
    public JsonData uUpdate(
            @ApiParam(value = "uUpdate") @RequestBody CustomerContactDTO contactDTO) {
        return contactService.uUpdate(contactDTO);
    }

    @ApiOperation("客户模块-关系人列表")
    @GetMapping("uContactList")
    public JsonData uContactList(
            @ApiParam(value = "当前页数") @RequestParam(value = "page", defaultValue = "1") int page,
            @ApiParam(value = "当页数目") @RequestParam(value = "size", defaultValue = "10") int size,
            @ApiParam(value = "客户编号") @RequestParam(value = "customerNo", defaultValue = "null") String customerNo,
            @ApiParam(value = "项目id") @RequestParam(value = "projectId", defaultValue = "-1") int projectId,
            @ApiParam(value = "类型：客户关系人1 客户来源2，合伙人4 ") @RequestParam(value = "type", defaultValue = "-1") int type) {
        Map<String,Object> contactDtoList =  contactService.uContactList(page, size, customerNo, projectId, type);
        return JsonData.buildSuccess(contactDtoList);
    }
}

